﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class ApplicationPlatform
{
    public static string GetRunPlatform()
    {
        string platform = "";

        switch (Application.platform)
        {
            case RuntimePlatform.Android:
                return "Android";

            case RuntimePlatform.WindowsEditor:
            case RuntimePlatform.WindowsPlayer:
                return "Windows";

            case RuntimePlatform.IPhonePlayer:
                return "IOS";
            case RuntimePlatform.OSXEditor:
            case RuntimePlatform.OSXPlayer:
                return "OSX";
        }
        return platform;
    }


    public static string GetPersistentDataPath(string path)
    {
        string tempPath = "";
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
        tempPath = "file:///" + path;
#elif UNITY_ANDROID
        tempPath = "file:///" + path;
#elif UNITY_IPHONE
        tempPath = path;
#endif
        return tempPath;
    }

    public static string GetResPath()
    {
        string path = "";

#if UNITY_EDITOR
            if (ApplicationPlatform.GetRunPlatform() == "Windows" || ApplicationPlatform.GetRunPlatform() == "IOS")
            {
                path = "file://" + Application.streamingAssetsPath + "/";
            }
            else
            {
                path = Application.streamingAssetsPath + "/";
            }
#elif UNITY_ANDROID
                        path = "jar:file:///"+Application.persistentDataPath + "/Res/";  
#elif UNITY_IPHONE
                        path = Application.persistentDataPath + "/Res/";
#elif UNITY_STANDALONE_WIN
                            path = "file:///" + Application.persistentDataPath + "/Res/";
#endif
        //path = "file:///" + Application.persistentDataPath + "/Res/";
        //path = "jar:file://" + Application.dataPath + "!/assets/Res/";
        path = Application.streamingAssetsPath + "/";
        Loger.Info("ApplicationPlatform", "GetStreamingAssetsPath--->Path:" + path);
        return path;
    }



    public static string GetStreamingAssetsPath()
    {
        string path = "";

        if (ApplicationPlatform.GetRunPlatform() == "Windows" || ApplicationPlatform.GetRunPlatform() == "IOS")
        {
            path = "file://" + Application.streamingAssetsPath + "/";
        }
        else
        {
            path = Application.streamingAssetsPath + "/";
        }
        return path;
    }

}
